package com.example.xlmkotlinwanandroid.learn

/**
 *  author : cailei
 *  date : 2022/3/10
 *  description :
 */
class SingleCase private constructor(val args: String) {

    companion object {
        @Volatile
        private var INSTANCE: SingleCase? = null

        fun getInstance(hello: String): SingleCase = INSTANCE ?: synchronized(this) {
            INSTANCE ?: SingleCase(hello).also { INSTANCE = it }
        }

    }

}


class SingleCase2 private constructor() {

    fun getInstance(): SingleCase2 {
        return InnerClass.instance
    }

    class InnerClass {
        companion object {
            val instance: SingleCase2 = SingleCase2()
        }
    }
}